﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using IFDB.Models.Contexts;
using IFDB.ResourceLibrary;

namespace IFDB.Models.Tables
{
    public class Team
    {
        public Team()
        {
            this.AppearanceEvents = new HashSet<AppearanceEvent>();
            this.LookupTeams = new HashSet<LookupTeam>();
            this.Team1Matches = new HashSet<Match>();
            this.Team2Matches = new HashSet<Match>();
            this.TeamNames = new HashSet<TeamName>();
            this.TeamBadges = new HashSet<TeamBadge>();
        }

        [Key]
        public Guid TeamId { get; set; }

        public virtual ICollection<AppearanceEvent> AppearanceEvents { get; set; }
        public virtual ICollection<LookupTeam> LookupTeams { get; set; }

        public virtual ICollection<TeamBadge> TeamBadges { get; set; }
        public virtual ICollection<TeamName> TeamNames { get; set; }

        [InverseProperty("Team1")]
        public virtual ICollection<Match> Team1Matches { get; set; }

        [InverseProperty("Team2")]
        public virtual ICollection<Match> Team2Matches { get; set; }

        public static Team CreateNew()
        {
            return new Team()
            {
                TeamId = Guid.NewGuid()
            };
        }
    }
}
